<style type="text/css">
    .bckcolor {
        background-color: #FF0000;
    }

    table tr {
        height: 32px;
    }
</style>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <input type="text" ng-model="info.plan_name" style="width: 300px;"
                           placeholder="Search Plan Name Or Ucloud Ip Here..."/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" data-ng-model="info.isOnlyoverdue" ng-change="record_list();"
                           ng-true-value="true" ng-false-value="false"/>
                    <span>只显示过期申请</span>
                    <input type="checkbox" style="margin-left: 30px;" data-ng-model="info.isOnlyOneMouth"
                           ng-change="record_list();"
                           ng-true-value="true" ng-false-value="false"/>
                    <span>只显示一个月内申请</span>
                    <img src="/beetle/image/icon_plus-box.png" ng-click="add();" style="cursor: pointer;">
                    <br>
                    <br>
                    <span style="color: #3c8dbc;">
                        <i class="fa fa-question-circle"></i>
                        <span>如果uCloud一直处在<span style="color: red;">申请中</span> , 请联系uCloud审批负责人(万敏).</span>
                    </span>
                </div>
                <div class="box-body" style=" ">
                    <table class="table table-hover table-bordered text-center">
                        <thead>
                        <tr>
                            <th width="10%">项目</th>
                            <th width="5%">环境</th>
                            <th width="5%">是否外网</th>
                            <th width="5%">到期保留</th>
                            <th width="10%">申请人</th>
                            <th width="8%">项目开始</th>
                            <th width="10%">项目结束</th>
                            <th width="10%">环境申请</th>
                            <th width="10%">环境审批</th>
                            <th width="10%">环境交付</th>
                            <th width="15%">区域需求</th>
                            <th width="8%">状态</th>
                            <th width="10%">ucloud-ip</th>
                            <th width="17%">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="i in info.recordlist |applyFilter:info.plan_name |paging:page.index:page.size track by $index">
                            <td>
                                <div ng-if="i.plan_name==''">
                                    -
                                </div>
                                <div ng-if="i.plan_name!=''">
                                    {{i.plan_name}}
                                </div>
                            </td>
                            <td>
                                {{i.type}}
                            </td>
                            <td>
                                <span ng-if="i.isUseWeb == '0'" uib-popover="{{i.useWebDesc}}"
                                      popover-trigger="mouseenter" style="color: red;">是</span>
                                <span ng-if="i.isUseWeb != '0'">否</span>
                            </td>
                            <td>
                                <span ng-if="i.isKeep == '0'" style="color: red;">是</span>
                                <span ng-if="i.isKeep != '0'">否</span>
                            </td>
                            <td>
                                {{i.applicant_name}}
                            </td>
                            <td>
                                {{i.start_date}}
                            </td>
                            <td>
                                {{i.expect_recover_date}}
                            </td>
                            <td>
                                {{i.create_date | date:'yyyy-MM-dd HH:mm':'UTC'}}
                            </td>
                            <td>
                                {{i.audit_time | date:'yyyy-MM-dd HH:mm':'UTC'}}
                            </td>
                            <td>
                                {{i.hand_time | date:'yyyy-MM-dd HH:mm':'UTC'}}
                            </td>
                            <td>
                                <div ng-if='i.desc!="" && i.desc != null'>
                                    <a id="configInfo" href="javascript:void(0)" class="btn-link" type="button"
                                       style="padding-left: 5%;" data-container="body" data-toggle="popover"
                                       data-placement="bottom" data-content="{{i.desc}}" data-html="true"
                                       data-trigger="hover">{{i.desc | limitTo : 10}}...</a>
                                </div>
                                <div ng-if='i.desc=="" || i.desc == null'>
                                    -
                                </div>
                            </td>
                            <td>
                                {{i.status}}
                            </td>
                            <td>
                                <div ng-if="i.agent_ip_bak!=null">
                                    <a href="javascript:void(0);" class="btn-link" type="button"
                                       ng-click="toAgent(i.agent_ip_bak);">{{i.agent_ip_bak}}</a>
                                </div>
                                <div ng-if="i.agent_ip_bak==null&&i.agent_ip!=null">
                                    <a href="javascript:void(0);" class="btn-link" type="button"
                                       ng-click="toAgent(i.agent_ip);">{{i.agent_ip}}</a>
                                </div>
                                <div ng-if="i.agent_ip_bak==null&&i.agent_ip==null">
                                    -
                                </div>
                            </td>
                            <td>
                                <div ng-if="!isIntegration(i.agent_ip)">
                                    <a href="javascript:void(0)"
                                       ng-if="i.status=='申请中' && (roleContain('admin') || roleContain('audit'))"
                                       ng-click="Examination(i);">审批</a>
                                    <a href="javascript:void(0)"
                                       ng-if="i.status!='申请中' && (roleContain('admin') || roleContain('assign'))"
                                       ng-click="Examination(i);">分配</a>
                                    <a href="javascript:void(0)"
                                       ng-if="i.agent_ip!=null && (roleContain('admin') || roleContain('assign'))"
                                       ng-click="recoverAgent(i);">回收</a>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <uib-pagination total-items="info.recordlist |applyFilter:info.plan_name |filter:filter|size"
                                ng-model="page.index" max-size="5"
                                previous-text="上一页" next-text="下一页" first-text="首页" last-text="尾页"
                                items-per-page="page.size" class="pagination-sm pull-right"
                                boundary-links="true"></uib-pagination>
            </div>
        </div>
    </div>
</section>
<script type="text/ng-template" id="Examination.html">
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="{{title}}" is-open="true">
                                <table width="95%">
                                    <tbody>
                                    <tr>
                                        <td> 开始日期:</td>
                                        <td>
                                            {{info.start_date | date:'yyyy-MM-dd'}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>项目到期:</td>
                                        <td>
                                            {{info.expect_recover_date | date:'yyyy-MM-dd'}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>区域要求:</td>
                                        <td>
                                            {{info.desc}}
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>批准硬件规模:</td>
                                        <td ng-if="info.typeName == '0'">
                                            <select ng-model="info.level_name">
                                                <option value="">请选择</option>
                                                <option ng-repeat="x in level_list" value="{{x.level_name}}">
                                                    {{x.level_name}}
                                                </option>
                                            </select>
                                        </td>
                                        <td ng-if="info.typeName == '1'">
                                            {{info.apply_load_level_name}}
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>补充说明:</td>
                                        <td>
                                            <textarea style="width: 361px; height: 96px;" ng-model="info.added_desc"
                                                      ng-disabled="info.typeName != '0'"></textarea>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>审核人:</td>
                                        <td>
                                            {{userName}}
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;" ng-if="info.typeName == '1'">
                                        <td>ucloud_ip:</td>
                                        <td>
                                            <select ng-model="info.ip">
                                                <option value="">请选择</option>
                                                <option ng-repeat="x in ucloud_agent" value="{{x.ip}}">{{x.ip}}</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <td colSpan=2 ng-if="info.typeName == '1'">
                                        <div align=center>
                                            <label style="padding-right:290px;">
                                                <input type="checkbox"
                                                       ng-model="info.isfalse"
                                                       ng-true-value="true"
                                                       ng-false-value="false"/>立即跳转到虚拟机列表进行初始化
                                            </label>
                                        </div>
                                    </td>
                                    </tbody>
                                </table>
                            </uib-accordion-group>
                        </uib-accordion>
                        <div class="modal-footer">
                            <button class="btn btn-warning" type="button" ng-click="save()">save</button>
                            <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</script>


<script type="text/ng-template" id="add.html">
    <style type="text/css">
        .switch {
            width: 28px;
            height: 14px;
        }

        .switch small {
            width: 14px;
            height: 14px;
        }

        .switch.checked small {
            left: 13px;
        }

        .dropdown-menu {
            max-height: 303px;
        }
    </style>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="{{title}}" is-open="true">
                                <table width="95%">
                                    <tbody>
                                    <tr>
                                        <td><span style="color: red;">*</span>开始日期:</td>
                                        <td>
                                            <p class="input-group">
                                                <input clear-text="清除" close-text="关闭" current-text="今天"
                                                       ng-readonly="true"
                                                       type="text" class="form-control" uib-datepicker-popup
                                                       ng-model="info.startExceptTime"
                                                       is-open="startExceptTimeOpened" ng-required="true"
                                                       close-text="Close"/>
                                                <span class="input-group-btn">
                                            <button type="button" class="btn btn-default"
                                                    ng-click="startExceptTimeOpened=!startExceptTimeOpened"><i
                                                    class="glyphicon glyphicon-calendar"></i></button>
                                        </span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <p class="input-group">
                                                <span ng-show="startTime"><b style="color: red;">请选择开始时间！</b></span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><span style="color: red;">*</span>项目到期:</td>
                                        <td>
                                            <p class="input-group">
                                                <input clear-text="清除" close-text="关闭" current-text="今天"
                                                       ng-readonly="true"
                                                       type="text" class="form-control" uib-datepicker-popup
                                                       ng-model="info.endExceptTime"
                                                       is-open="endExceptTimeOpened" ng-required="true"
                                                       close-text="Close"/>
                                                <span class="input-group-btn">
                                            <button type="button" class="btn btn-default"
                                                    ng-click="endExceptTimeOpened=!endExceptTimeOpened"><i
                                                    class="glyphicon glyphicon-calendar"></i></button>
                                        </span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <p class="input-group">
                                                <span ng-show="endTime"><b style="color: red;">请选择项目到期时间！</b></span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>备注:</td>
                                        <td>
                                            <textarea style="width: 361px; height: 96px;"
                                                      ng-model="info.desc"
                                                      placeholder="填写特殊要求，如指定机器ip为172.16.2.27"></textarea>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>申请人:</td>
                                        <td>
                                            {{userName}}
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td><span style="color: red;">*</span>项目:</td>
                                        <td>
                                            <input type="text" ng-model="info.selectPlan" placeholder="Select Plan"
                                                   uib-typeahead="plan as plan.plan_name for plan in info.planList | filter:{plan_name:$viewValue}|limitTo:15"
                                                   typeahead-template-url="selectTemplate.html" class="form-control"
                                                   typeahead-show-hint="true" typeahead-min-length="0">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <p class="input-group">
                                                <span ng-show="showPlanError"><b style="color: red;">请选择项目！</b></span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>环境:</td>
                                        <td>
                                            <select ng-model="info.type">
                                                <option value="DEV">DEV</option>
                                                <option value="QA">QA</option>
                                                <option value="UAT">UAT</option>
                                            </select>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </uib-accordion-group>
                        </uib-accordion>
                        <div class="modal-footer">
                            <button class="btn btn-warning" type="button" ng-click="save()">save</button>
                            <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</script>